set nu
set tabstop=4
set softtabstop=4
set shiftwidth=4
set cindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s

"高亮行
set cul
"set cuc "高亮列
set scrolloff=3     " 光标移动到buffer的顶部和底部时保持3行距离
set showcmd         " 输入的命令显示出来，看的清楚些
"将tab替换为空格 
nmap tt :%s/\t/    /g<CR> 


"debian语法高亮
if has("syntax")
   syntax on           
endif

"C，C++ 按F5编译运行 
map <F5> :call CompileRunGcc()<CR> 
func! CompileRunGcc() 
    exec "w" 
    if &filetype == 'c' 
        exec "!g++ % -o %<" 
        exec "!time ./%<" 
    elseif &filetype == 'cpp' 
        exec "!g++ % -o %<" 
        exec "!time ./%<" 
    elseif &filetype == 'java'  
        exec "!javac %"  
        exec "!time java %<" 
    elseif &filetype == 'sh' 
        :!time bash % 
    elseif &filetype == 'python' 
        exec "!time python2.7 %" 
    elseif &filetype == 'html' 
        exec "!firefox % &" 
    elseif &filetype == 'go' 
        "exec "!go build %<" 
        exec "!time go run %" 
    "elseif &filetype == 'mkd' 
    "    exec "!~/.vim/markdown.pl % > %.html &" 
    "    exec "!firefox %.html &" 
    endif 
endfunc 

"C,C++的调试 
map <F8> :call Rungdb()<CR> 
func! Rungdb() 
    exec "w" 
    exec "!g++ % -g -o %<" 
    exec "!gdb ./%<" 
endfunc 



"nerd_tree, 显示目录, 需将文件解压到对应的目录
map <F3> :NERDTreeMirror<CR>
map <F3> :NERDTreeToggle<CR>
"当打开vim且没有文件时自动打开NERDTree
autocmd vimenter * if !argc() | NERDTree | endif
" 只剩 NERDTree时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" 设置当文件被改动时自动载入
set autoread


"共享剪贴板  
set clipboard+=unnamed
" 高亮显示匹配的括号 
set showmatch 
" 匹配括号高亮的时间（单位是十分之一秒） 
set matchtime=1 



"设置tags文件,找不到自动向上级目录查找
set tags=tags
set autochdir

"windows gvim 配置
"设置修改后不生成备份文件
"set nobackup
"设置字体和大小
"set guifont=Consolas:h11
"中文乱码
"set encoding=utf-8
"set fileencodings=utf-8,gbk,gb18030,gk2312
"language messages zh_CN.utf-8
"colorscheme torte
"source $VIMRUNTIME/delmenu.vim
"source $VIMRUNTIME/menu.vim

